<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Connect to the service manager</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="function.ibase-server-info.html">« ibase_server_info</a></li>
      <li style="float: right;"><a href="function.ibase-service-detach.html">ibase_service_detach »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="ref.ibase.html">Firebird/InterBase 函数</a></li>
    <li>Connect to the service manager</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="function.ibase-service-attach" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">ibase_service_attach</h1>
  <p class="verinfo">(PHP 5, PHP 7 &lt; 7.4.0)</p><p class="refpurpose"><span class="refname">ibase_service_attach</span> &mdash; <span class="dc-title">Connect to the service manager</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.ibase-service-attach-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>ibase_service_attach</strong></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$host</code></span>, <span class="methodparam"><span class="type">string</span> <code class="parameter">$dba_username</code></span>, <span class="methodparam"><span class="type">string</span> <code class="parameter">$dba_password</code></span>): <span class="type"><span class="type">resource</span>|<span class="type"><span class="type false">false</span></span></span></div>

 </div>

 
 <div class="refsect1 parameters" id="refsect1-function.ibase-service-attach-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>
    
     <dt>
<code class="parameter">host</code></dt>

     <dd>

      <p class="para">
       The name or ip address of the database host. You can define the port by adding 
       &#039;/&#039; and port number. If no port is specified, port 3050 will be used.
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">dba_username</code></dt>

     <dd>

      <p class="para">
       The name of any valid user.
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">dba_password</code></dt>

     <dd>

      <p class="para">
       The user&#039;s password.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.ibase-service-attach-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   Returns a Interbase / Firebird link identifier on success 或者在失败时返回 <strong><code>false</code></strong>.
  </p>
 </div>

 
 <div class="refsect1 examples" id="refsect1-function.ibase-service-attach-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-1236">
    <p><strong>示例 #1 <span class="function"><strong>ibase_service_attach()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;Attach&nbsp;to&nbsp;the&nbsp;remote&nbsp;Firebird&nbsp;server&nbsp;by&nbsp;ip&nbsp;address<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">if&nbsp;((</span><span style="color: #0000BB">$service&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">ibase_service_attach</span><span style="color: #007700">(</span><span style="color: #DD0000">'10.1.1.199'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'sysdba'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'masterkey'</span><span style="color: #007700">))&nbsp;!=&nbsp;</span><span style="color: #0000BB">FALSE</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;Successfully&nbsp;attached.&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;Fetch&nbsp;server&nbsp;version&nbsp;(something&nbsp;like&nbsp;'LI-V3.0.4.33054&nbsp;Firebird&nbsp;3.0')<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$server_version&nbsp;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">ibase_server_info</span><span style="color: #007700">(</span><span style="color: #0000BB">$service</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">IBASE_SVC_SERVER_VERSION</span><span style="color: #007700">);<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;Fetch&nbsp;server&nbsp;implementation&nbsp;(something&nbsp;like&nbsp;'Firebird/Linux/AMD/Intel/x64')<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$server_implementation&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">ibase_server_info</span><span style="color: #007700">(</span><span style="color: #0000BB">$service</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">IBASE_SVC_IMPLEMENTATION</span><span style="color: #007700">);<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;Detach&nbsp;from&nbsp;server&nbsp;(disconnect)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">ibase_service_detach</span><span style="color: #007700">(</span><span style="color: #0000BB">$service</span><span style="color: #007700">);<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;Output&nbsp;the&nbsp;info<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">echo&nbsp;</span><span style="color: #DD0000">"Server&nbsp;version:&nbsp;"&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">$server_version&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #DD0000">"&lt;br/&gt;"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"Server&nbsp;implementation:&nbsp;"&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">$server_implementation</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;else&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;Output&nbsp;message&nbsp;on&nbsp;error<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$conn_error&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">ibase_errmsg</span><span style="color: #007700">();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;die(</span><span style="color: #0000BB">$conn_error</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
  </p>
  
  <p class="para">
   <div class="example" id="example-1237">
    <p><strong>示例 #2 <span class="function"><strong>ibase_service_attach()</strong></span> example using <code class="literal">hostname/port</code> syntax</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;Attach&nbsp;to&nbsp;the&nbsp;remote&nbsp;Firebird&nbsp;server&nbsp;by&nbsp;name.&nbsp;Use&nbsp;Port&nbsp;3050.<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">if&nbsp;((</span><span style="color: #0000BB">$service&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">ibase_service_attach</span><span style="color: #007700">(</span><span style="color: #DD0000">'FB-SRV-01.contoso.local/3050'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'sysdba'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'masterkey'</span><span style="color: #007700">))&nbsp;!=&nbsp;</span><span style="color: #0000BB">FALSE</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;Successfully&nbsp;attached.&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;Fetch&nbsp;server&nbsp;version&nbsp;(something&nbsp;like&nbsp;'LI-V3.0.4.33054&nbsp;Firebird&nbsp;3.0')<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$server_version&nbsp;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">ibase_server_info</span><span style="color: #007700">(</span><span style="color: #0000BB">$service</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">IBASE_SVC_SERVER_VERSION</span><span style="color: #007700">);<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;Fetch&nbsp;server&nbsp;implementation&nbsp;(something&nbsp;like&nbsp;'Firebird/Linux/AMD/Intel/x64')<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$server_implementation&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">ibase_server_info</span><span style="color: #007700">(</span><span style="color: #0000BB">$service</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">IBASE_SVC_IMPLEMENTATION</span><span style="color: #007700">);<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;Detach&nbsp;from&nbsp;server&nbsp;(disconnect)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">ibase_service_detach</span><span style="color: #007700">(</span><span style="color: #0000BB">$service</span><span style="color: #007700">);<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;Output&nbsp;the&nbsp;info<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">echo&nbsp;</span><span style="color: #DD0000">"Server&nbsp;version:&nbsp;"&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">$server_version&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #DD0000">"&lt;br/&gt;"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"Server&nbsp;implementation:&nbsp;"&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">$server_implementation</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;else&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;Output&nbsp;message&nbsp;on&nbsp;error<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$conn_error&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">ibase_errmsg</span><span style="color: #007700">();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;die(</span><span style="color: #0000BB">$conn_error</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.ibase-service-attach-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="function.ibase-service-detach.html" class="function" rel="rdfs-seeAlso">ibase_service_detach()</a> - Disconnect from the service manager</span></li>
   </ul>
  </p>
 </div>


</div></div></div></body></html>